function createXMLHttpRequest()
{
	var xmlhttp;	
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	return xmlhttp;
}

function showListTitle(str)
{	
  	xmlhttp = createXMLHttpRequest();
  
	xmlhttp.onreadystatechange=function()
  	{
  		if (xmlhttp.readyState==4 && xmlhttp.status==200)
    	{
    		document.getElementById("titlelist").innerHTML=xmlhttp.responseText;
    	}
  	}
	var serverURL = "get_news.php?currentpage="+ encodeURI(str) + "&t=" + (new Date()).getTime();
	xmlhttp.open("POST",serverURL,true);
	xmlhttp.send();
}

function showall(str, i)
{
    showImg(str);
    showContent(str);
    showTitle(str);
    changestyle(str, i);
}



function showTitle(str)
{
    document.getElementById("tit").innerHTML = document.getElementById("tit"+str).innerHTML;
}

function changestyle(str, i)
{
    document.getElementById("tit"+str).className = "btn blue";
    if(i == 0)
        {
                str = str +1;
                document.getElementById("tit"+str).className = "btn";
                str = str + 1;
                document.getElementById("tit"+str).className = "btn";
        }

    if(i==1)
        {
                str = str - 1;
                document.getElementById("tit"+str).className = "btn";
                str = str + 2;
                document.getElementById("tit"+str).className = "btn";
        }
    if(i==2)
        {
                str = str - 1;
                document.getElementById("tit"+str).className = "btn";
                str = str - 1;
                document.getElementById("tit"+str).className = "btn";
        }
       

}

function showImg(str)
{
      	xmlhttp1 = createXMLHttpRequest();
  
	xmlhttp1.onreadystatechange=function()
  	{
  		if (xmlhttp1.readyState==4 && xmlhttp1.status==200)
    	{
    		document.getElementById("newsimg").src = xmlhttp1.responseText;
    	}
  	}
	var serverURL = "get_news_img.php?q="+ encodeURI(str) + "&t=" + (new Date()).getTime();
	xmlhttp1.open("POST",serverURL,true);
	xmlhttp1.send();
}

function showContent(str)
{
        xmlhttp = createXMLHttpRequest();
  
	xmlhttp.onreadystatechange=function()
  	{
  		if (xmlhttp.readyState==4 && xmlhttp.status==200)
    	{
    		document.getElementById("contentnews").innerHTML=xmlhttp.responseText;
    	}
  	}
	var serverURL = "get_news_content.php?q="+ encodeURI(str) + "&t=" + (new Date()).getTime();
	xmlhttp.open("POST",serverURL,true);
	xmlhttp.send();
}


 function showall1(str)
{
    showImg1(str);
    showContent1(str);
    showTitle1(str);
    changeStyle1(str);
}

 function showImg1(str)
{
    str = str - 1;
    var img = ["http://vang-24h.com.vn/uploads/hinhanh/tinkhac/Fed%204.jpg", "http://www.bullionstreet.com/uploads/news/2011/9/1317369027.jpg", "http://www.fairloanrate.com/wp-content/uploads/2009/09/fomc.jpg"];
    document.getElementById("newsimg").src = img[str];
}

function showContent1(str)
{
    str = str - 1;
    var content = ["this is the content of 1", "this is the content of 2", "this is the content of 3"];
    document.getElementById("contentnews").innerHTML = content[str];
}

function showTitle1(str)
{
    document.getElementById("title").innerHTML = "<h3>" + document.getElementById("title"+str).innerHTML + "</h3>";
}

function changeStyle1(str)
{
    document.getElementById("title"+str).className = "btn blue";
    if(str==1)
        {
                str = str + 1;
                document.getElementById("title2").className = "btn";
                str = str + 1;
                document.getElementById("title3").className = "btn";
        }
        else
            {
                if(str==2)
                    {
                            str = str - 1;
                            document.getElementById("title"+str).className = "btn";
                            str = str + 2;
                            document.getElementById("title"+str).className = "btn";
                    }
                else
                    {
                        if(str==3)
                            {
                                    str = str - 1;
                                    document.getElementById("title"+str).className = "btn";
                                    str = str - 1;
                                    document.getElementById("title"+str).className = "btn";
                            }
                    }
            }
       

}

function onlyNumbers(evt)
{
	var e = event || evt; // for trans-browser compatibility
	var charCode = e.which || e.keyCode;

	if (charCode > 31 && (charCode < 48 || charCode > 57))
                    if(charCode != 46)
		return false;

	return true;

}